{extend name="base" /} {block name="body"}
<style>
    .coverBox {
        position: absolute;
        right: 105px;
        bottom: 30px;
        z-index: 1000;
        background: #fff;
        height: 300px;
        width: 450px;
    }

    .coverBox span {
        position: absolute;
        background: rgba(10, 10, 10, .4);
        padding: 5px;
        bottom: 1px;
        cursor: pointer;
        font-size: 10px;
        color: #ffffff;
    }

    .coverBox img {
        width: 100%;
        height: 100%;
    }

    .coverBox .recheck {
        right: 1px;
    }

    .coverBox .removeCove {
        left: 1px;
    }
</style>
<div class="layui-tab layui-tab-brief">
    <ul class="layui-tab-title">
        <li class="layui-this">编辑用户</li>
    </ul>
</div>
<!--tab标签-->
<div class="layui-tab-brief">

    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <form class="layui-form form-container" data-url="{:url('admin/user/update')}"
                  localtion-url="{:url('admin/user/index')}">
                <div class="layui-form-item">
                    <label class="layui-form-label">用户名</label>
                    <div class="layui-input-inline">
                        <input type="text" name="username" value="{$user.username}" required lay-verify="required"
                               autocomplete="off"    placeholder="请输入用户名" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">昵称</label>
                    <div class="layui-input-inline">
                        <input type="text" name="nickname" value="{$user.nickname}" required lay-verify="required"
                               autocomplete="off"    placeholder="输入昵称" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">密码</label>
                    <div class="layui-input-inline">
                        <input type="password" name="password" value="" autocomplete="off"  placeholder="（选填）如不修改则留空" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">手机</label>
                    <div class="layui-input-inline">
                        <input type="text" name="mobile" value="{$user.mobile}" autocomplete="off" placeholder="（选填）请输入手机"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">QQ</label>
                    <div class="layui-input-inline">
                        <input type="text" name="qq_id" value="{$user.qq_id}" autocomplete="off"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">邮箱</label>
                    <div class="layui-input-inline">
                        <input type="email" name="email" value="{$user.email}"
                               autocomplete="off"  placeholder="请输入邮箱" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">头像</label>
                    <div class="layui-input-inline" style="width: auto;margin-right:0px">
                        <button type="button" class="layui-btn" id="image">
                            <i class="layui-icon">&#xe67c;</i>上传图片
                        </button>
                    </div>
                    <div class="layui-input-inline" style="width: calc(100% - 300px);">
                        <input type="text" id="cover_img" name="avatar" value="{$user.avatar}" class="layui-input">
                    </div>
                    <div class="coverBox" hidden >
                        <img src="__ADMIN__/images/default.png" alt="">
                    </div>
                    <div class="layui-input-inline" style="width: 20px;" id="viewCoverPic">

                        <a class="layui-btn layui-btn-primary" >预览</a>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">发文免审</label>
                    <div class="layui-input-inline">
                        <input type="radio" name="no_audit" value="1" title="免审" {if condition="$user.no_audit eq 1" }
                               checked="checked" {/if}>
                        <input type="radio" name="no_audit" value="0" title="需审" {if condition="$user.no_audit eq 0" }
                               checked="checked" {/if}>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">系统专用</label>
                    <div class="layui-input-inline">
                        <input type="radio" name="system_used" value="1" title="专用" {if
                               condition="$user.system_used eq 1" } checked="checked" {/if}>
                        <input type="radio" name="system_used" value="0" title="普通" {if
                               condition="$user.system_used eq 0" } checked="checked" {/if}>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-inline">
                        <input type="radio" name="status" value="1" title="启用" {if condition="$user.status gt 0" }
                               checked="checked" {/if}>
                        <input type="radio" name="status" value="0" title="禁用" {if condition="$user.status elt 0" }
                               checked="checked" {/if}>
                    </div>
                </div>
                <div class="btable-paged">
                    <div class="formbtngroup">
                        <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="formadd">提交</button>
                        <button onclick="history.go(-1);return false;" class="layui-btn layui-btn-primary layui-btn-sm">
                            返回
                        </button>
                    </div>
                </div>
                <input type="hidden" name="id" value="{$user.id}">
            </form>
        </div>
    </div>
</div>

{/block} {block name="js"}
<script type="text/javascript" src="__ADMIN__/js/formadd.js"></script>
<script>
    layui.use(['form','upload'], function () {
        var form = layui.form,
            upload = layui.upload,
            jq = layui.jquery;
        var uploadImg = jq("#image");
        upload.render({
            elem: '#image',
            url: "{:url('upload/upimage')}",
            done: function (res) {
                if (res.code == '0') {
                    jq('input[name=avatar]').val(res.data.src);
                    return layer.msg('上传成功');
                } else {

                    return layer.msg(res.msg);
                }

            }
        });
        jq('#viewCoverPic').hover(function () {
            var box = $("div.coverBox");
            if (jq('#cover_img').val().length>10){
                box.fadeIn(200);   box.find("img")[0].src=jq('#cover_img').val();
            }
        },function () {
            jq("div.coverBox").fadeOut(100)
        });
    });
</script>
{/block}